<?php
/**
 * 存储类型设置
**/
define('IN_ADMIN', true);
include("../includes/common.php");
$title='存储类型设置';
include './head.php';
if($islogin==1){}else loginmsg('请登录后再操作！');
?>
<div class="layui-fluid">
<div class="col-xs-12 col-sm-10 col-lg-8 center-block" style="float: none;">
	<div class="layui-card">
		<div class="layui-card-header">存储类型设置</div>


		<form method="post" class="layui-form" id="formAdvForm" lay-filter="formAdvForm">
                    <div class="layui-form-item">
                        <label class="layui-form-label">默认存储</label>
                        <div class="layui-input-block">
                            <select name="storage" lay-verify="required">
                                <option value="local" <?php echo $conf['storage']=='local'?'selected':''; ?>>本地存储</option>
                                <option value="oss" <?php echo $conf['storage']=='oss'?'selected':''; ?>>阿里云OSS</option>
                                <option value="qcloud" <?php echo $conf['storage']=='qcloud'?'selected':''; ?>>腾讯云COS</option>
                                <option value="obs" <?php echo $conf['storage']=='obs'?'selected':''; ?>>华为云OBS</option>
                                <option value="upyun" <?php echo $conf['storage']=='upyun'?'selected':''; ?>>又拍云</option>
                                <option value="qiniu" <?php echo $conf['storage']=='qiniu'?'selected':''; ?>>七牛云</option>
                                <?php if (defined('SAE_ACCESSKEY')) {?>
                                <option value="sae" <?php echo $conf['storage']=='sae'?'selected':''; ?>>SaeStorage</option>
                                <?php }?>
                            </select>
                            <div class="form-tips">用户未登录或未开通会员时默认使用本存储方式</div>
                        </div>
                    </div>
					
                    
                    <!-- 这里可以添加其他表单元素 -->

					<div class="layui-form-item">
                    	<label class="layui-form-label">文件上传方式</label>
						<div class="layui-input-block">
							<select name="uploadfile_type" class="layui-input" default="<?=$conf['uploadfile_type']?>">
								<option <?php echo $conf['uploadfile_type'] == 0 ? 'selected ' : '' ?>value="0">网站中转</option>
								<option <?php echo $conf['uploadfile_type'] == 1 ? 'selected ' : '' ?>value="1">直接链接</option>
							</select>
						</div>
                     </div>

					 <div class="layui-form-item">
                    	<label class="layui-form-label">文件下载方式</label>
						<div class="layui-input-block">
							<select name="downfile_type" class="layui-input" default="<?=$conf['downfile_type']?> lay-filter="downfile_type">
								<option <?php echo $conf['downfile_type'] == 0 ? 'selected ' : '' ?>value="0">网站中转</option>
								<option <?php echo $conf['downfile_type'] == 1 ? 'selected ' : '' ?>value="1">直接链接</option>
							</select>
						</div>
                     </div>

                     <?php if ($conf['downfile_type']==1) {?>
					 <div class="layui-form-item" id ="downfile_protocol">
                    	<label class="layui-form-label">文件下载域名</label>
						<div class="layui-input-block">
							<select name="downfile_protocol" class="layui-input" default="<?=$conf['downfile_protocol']?>">
								<option <?php echo $conf['downfile_protocol'] == 0 ? 'selected ' : '' ?>value="0">http://</option>
								<option <?php echo $conf['downfile_protocol'] == 1 ? 'selected ' : '' ?>value="1">https://</option>
							</select>
						</div>
						<!-- <div class="layui-input-block">
                            <input type="text" name="downfile_domain" class="layui-input" placeholder="留空则使用云存储默认域名" value="<?=$conf['downfile_domain']?>">
                         </div> -->
                     </div>
					<?php }?>

				<fieldset class="layui-elem-field">
                    <legend>文件上传方式说明：</legend>
                    <div class="layui-field-box">
						网站中转：上传文件先经过本站服务器，然后上传到云存储，速度较慢。<br/>
						直接链接：文件直接上传到云存储，不经过本站服务器，上传速度更快，支持更大文件。需要先在云存储设置跨域！<br/>
                    </div>
                </fieldset>


				<fieldset class="layui-elem-field">
                    <legend>文件下载方式说明：</legend>
                    <div class="layui-field-box">
						网站中转：下载文件经过本站服务器中转，如果本机与云存储是内网连接则不消耗流量。<br/>
						直接链接：需支付流量费用，下载速度更快。<br/>
                    </div>
                </fieldset>

                     <div class="layui-form-item text-right">
                  
                    <button class="layui-btn" type="button" lay-submit lay-filter="notice-btn">&emsp;提交&emsp;</button>
                </div>
                </form>

	</div>
           
			<div class="layui-card">
				<div class="layui-card-header">本地存储设置</div>
				<form method="post" class="layui-form" id="formAdvForm" lay-filter="formAdvForm">
							<div class="layui-form-item" >
								<label class="layui-form-label">本地存储路径</label>
								<div class="layui-input-block">
									<input type="text" name="filepath" class="layui-input" placeholder="默认存储在网站file目录" value="<?=$conf['filepath']?>">
								</div>
							</div>
						<fieldset class="layui-elem-field">
							<legend>文件上传方式说明：</legend>
							<div class="layui-field-box">
								不填写则默认存储在网站file目录下，如需填写，只能填写以服务器根目录/开始的绝对路径。<br/>
							</div>
						</fieldset>

							<div class="layui-form-item text-right">
								<button class="layui-btn" type="button" lay-submit lay-filter="notice-btn">&emsp;提交&emsp;</button>
							</div>
				</form>

			</div>
		


			
			<div class="layui-card">
				<div class="layui-card-header">阿里云OSS设置</div>
				<form method="post" class="layui-form" id="formAdvForm" lay-filter="formAdvForm">
							<div class="layui-form-item" >
								<label class="layui-form-label">阿里云AccessKey Id</label>
								<div class="layui-input-block">
									<input type="text" name="oss_ak" class="layui-input" placeholder="" value="<?=$conf['oss_ak']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">阿里云AccessKey Secret</label>
								<div class="layui-input-block">
									<input type="text" name="oss_sk" class="layui-input" placeholder="" value="<?=$conf['oss_sk']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">阿里云OSS EndPoint</label>
								<div class="layui-input-block">
									<input type="text" name="oss_endpoint" class="layui-input" placeholder="" value="<?=$conf['oss_endpoint']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">阿里云OSS Bucket</label>
								<div class="layui-input-block">
									<input type="text" name="oss_bucket" class="layui-input" placeholder="" value="<?=$conf['oss_bucket']?>">
								</div>
							</div>
							<div class="layui-form-item" >
								<label class="layui-form-label">自定义域名</label>
								<div class="layui-input-block">
									<input type="text" name="oss_url" class="layui-input" placeholder="" value="<?=$conf['oss_url']?>">
								</div>
							</div>
							<div class="layui-form-item text-right">
								<button class="layui-btn" type="button" lay-submit lay-filter="notice-btn">&emsp;提交&emsp;</button>
							</div>
				</form>

			</div>
			


			
			<div class="layui-card">
				<div class="layui-card-header">腾讯云COS设置</div>
				<form method="post" class="layui-form" id="formAdvForm" lay-filter="formAdvForm">
							<div class="layui-form-item" >
								<label class="layui-form-label">腾讯云SecretId</label>
								<div class="layui-input-block">
									<input type="text" name="qcloud_id" class="layui-input" placeholder="" value="<?=$conf['qcloud_id']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">腾讯云SecretKey</label>
								<div class="layui-input-block">
									<input type="text" name="qcloud_key" class="layui-input" placeholder="" value="<?=$conf['qcloud_key']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">COS存储桶地域</label>
								<div class="layui-input-block">
									<input type="text" name="qcloud_region" class="layui-input" placeholder="" value="<?=$conf['qcloud_region']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">COS存储桶名称</label>
								<div class="layui-input-block">
									<input type="text" name="qcloud_bucket" class="layui-input" placeholder="" value="<?=$conf['qcloud_bucket']?>">
								</div>
							</div>
							<div class="layui-form-item" >
								<label class="layui-form-label">自定义域名</label>
								<div class="layui-input-block">
									<input type="text" name="qcloud_url" class="layui-input" placeholder="" value="<?=$conf['qcloud_url']?>">
								</div>
							</div>
							<div class="layui-form-item text-right">
								<button class="layui-btn" type="button" lay-submit lay-filter="notice-btn">&emsp;提交&emsp;</button>
							</div>
				</form>

			</div>
		



			
			<div class="layui-card">
				<div class="layui-card-header">华为云OBS设置</div>
				<form method="post" class="layui-form" id="formAdvForm" lay-filter="formAdvForm">
							<div class="layui-form-item" >
								<label class="layui-form-label">华为云AccessKeyId</label>
								<div class="layui-input-block">
									<input type="text" name="obs_ak" class="layui-input" placeholder="" value="<?=$conf['obs_ak']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">华为云SecretAccessKey</label>
								<div class="layui-input-block">
									<input type="text" name="obs_sk" class="layui-input" placeholder="" value="<?=$conf['obs_sk']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">OBS EndPoint</label>
								<div class="layui-input-block">
									<input type="text" name="obs_endpoint" class="layui-input" placeholder="" value="<?=$conf['obs_endpoint']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">OBS桶名称</label>
								<div class="layui-input-block">
									<input type="text" name="obs_bucket" class="layui-input" placeholder="" value="<?=$conf['obs_bucket']?>">
								</div>
							</div>
							<div class="layui-form-item" >
								<label class="layui-form-label">自定义域名</label>
								<div class="layui-input-block">
									<input type="text" name="obs_url" class="layui-input" placeholder="" value="<?=$conf['obs_url']?>">
								</div>
							</div>
							<div class="layui-form-item text-right">
								<button class="layui-btn" type="button" lay-submit lay-filter="notice-btn">&emsp;提交&emsp;</button>
							</div>
				</form>

			</div>
		

		
			<div class="layui-card">
				<div class="layui-card-header">又拍云设置</div>
				<form method="post" class="layui-form" id="formAdvForm" lay-filter="formAdvForm">
							<div class="layui-form-item" >
								<label class="layui-form-label">云存储服务名称</label>
								<div class="layui-input-block">
									<input type="text" name="upyun_name" class="layui-input" placeholder="" value="<?=$conf['upyun_name']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">操作员名称</label>
								<div class="layui-input-block">
									<input type="text" name="upyun_user" class="layui-input" placeholder="" value="<?=$conf['upyun_user']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">操作员密码</label>
								<div class="layui-input-block">
									<input type="text" name="upyun_pwd" class="layui-input" placeholder="" value="<?=$conf['upyun_pwd']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">自定义域名</label>
								<div class="layui-input-block">
									<input type="text" name="upyun_url" class="layui-input" placeholder="" value="<?=$conf['upyun_url']?>">
								</div>
							</div>

							<div class="layui-form-item text-right">
								<button class="layui-btn" type="button" lay-submit lay-filter="notice-btn">&emsp;提交&emsp;</button>
							</div>
				</form>

			</div>
		


		
			<div class="layui-card">
				<div class="layui-card-header">七牛云设置</div>
				<form method="post" class="layui-form" id="formAdvForm" lay-filter="formAdvForm">
							<div class="layui-form-item" >
								<label class="layui-form-label">AccessKey</label>
								<div class="layui-input-block">
									<input type="text" name="qiniu_ak" class="layui-input" placeholder="" value="<?=$conf['qiniu_ak']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">SecretKey</label>
								<div class="layui-input-block">
									<input type="text" name="qiniu_sk" class="layui-input" placeholder="" value="<?=$conf['qiniu_sk']?>">
								</div>
							</div>

							<div class="layui-form-item" >
								<label class="layui-form-label">存储空间名称</label>
								<div class="layui-input-block">
									<input type="text" name="qiniu_bucket" class="layui-input" placeholder="" value="<?=$conf['qiniu_bucket']?>">
								</div>
							</div>
							<div class="layui-form-item" >
								<label class="layui-form-label">空间绑定域名</label>
								<div class="layui-input-block">
									<input type="text" name="qiniu_domain" class="layui-input" placeholder="" value="<?=$conf['qiniu_domain']?>">
								</div>
							</div>
							<div class="layui-form-item" >
								<label class="layui-form-label">自定义域名</label>
								<div class="layui-input-block">
									<input type="text" name="qiniu_url" class="layui-input" placeholder="" value="<?=$conf['qiniu_url']?>">
								</div>
							</div>

							<div class="layui-form-item text-right">
								<button class="layui-btn" type="button" lay-submit lay-filter="notice-btn">&emsp;提交&emsp;</button>
							</div>
				</form>

			</div>
		
	

</div>

</div>


<?php include 'foot.php';?>
<script>
		layui.use(['layer', 'form', 'element', 'jquery', 'tagsInput', 'admin', 'laydate', 'notice', 'upload'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var layer = layui.layer;
        var tagsInput = layui.tagsInput;
        var laydate = layui.laydate;
        var admin = layui.admin;
        var notice = layui.notice;
        var upload = layui.upload;


            
            // 监听提交
            form.on('submit(notice-btn)', function (data) { 
            notice.msg('正在修改配置中..', {icon: 4, close: true});
            $.ajax({
                type: "POST",
                url: "ajax.php?act=set",
                data: data.field,
                dataType: "json",
                success: function(data) {
                    notice.destroy();
                    if (data.code == 0) {
                        notice.success({
                            title: '消息通知',
                            message: '设置保存成功！',
                            position:'topCenter',
                            audio:''
                        });
                        setTimeout(function(){
                            location.reload();
                        }, 2500);
                    } else {
                        notice.error({
                            title: '消息通知',
                            message: data.msg,
                            position:'topCenter',
                            audio:''
                        });
                    }
                }
            });
            return false;
        });
            
            // 表单初始渲染
            form.render();
        });
	</script>
